package com.zlict.admin.controller;

import com.zlict.admin.service.BaseAreaService;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 省市区controller
 */
@RestController
@RequestMapping("/admin/area")
public class AreaController extends BaseController {

    @Autowired
    BaseAreaService baseAreaService;
    /**
     * 省
     */
    @GetMapping("/province")
    public AjaxResult province() {
        return success(baseAreaService.selectProvinceList());
    }
    /**
     * 市区
     */
    @GetMapping("/cityAndArea/{parentId}")
    public AjaxResult cityAndArea(@PathVariable("parentId") Integer parentId) {
        return success(baseAreaService.selectCityAndAreaByPid(parentId));
    }

}
